package com.liang.bishi.san60;

import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Test01 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        System.out.println(getMinWays(a));
    }

    public static int getMinWays(int[] a) {
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        for (int num : a) {
            pq.add(num);
        }
        int count = 0;
        while (pq.size() > 1) {
            int y = pq.poll();
            int x = pq.poll();
            if (x != y) {
                pq.add(x + y);
                count++;
            }
            pq.add(x);
        }
        return count;
    }

    public static int getMinWays2(int[] a) {
        int count = 0;
        Arrays.sort(a);
        int current = 0;
        for (int num : a) {
            if (num <= current) {
                count++;
                int diff = current - num + 1;
                current += diff;
            } else {
                current = num;
            }
        }
        return count;
    }
}